<template>
  <BaseCard class="h-full">
    <template #header>
      <div class="flex justify-between" >
        <span class="title">待办事项</span>
        <el-button type="primary" size="small" @click="gotoMore">更多</el-button>
      </div>
    </template>
    <div class="list-wrap" >
      <div class="head flex">
        <div class="flex-1" >标题</div>
        <div >办理模块</div>
        <div >申请时间</div>
        <div>操作</div>
      </div>
      <div class="list-items" v-if="needdoList.length>0" v-loading="loading">
        <div class="item flex" v-for="item in needdoList" >
             <div class="flex-1 truncate"  @click="openDetail(item)">
            {{item.businessName}}
          </div>
        
          <div class="">
            {{item.moduleNameShow}}
          </div>
          <div>{{item.createTime}}</div>
          <div class="operate"  @click="openDetail(item)"> 审核</div>
        </div>
      </div>
      <el-empty v-else description="暂无数据" />
    </div>
  </BaseCard>
    <ViewPage :isView="false" @AuthorSuccess="authorSuccess" ref="ViewPageRef" />
</template>

<script setup>
import BaseCard from "./BaseCard.vue";
import * as homeApi  from "@/api/home/index";
import { formatPast} from '@/utils/formatTime'
import { reactive } from "vue";
import ViewPage from "@/views/details/ViewPage"; //详情页
const router = useRouter();
const  needdoList=ref([]);
const ViewPageRef =ref();
const loading = ref(true);
const queryParam=reactive({
    pageNum: 1,
    pageSize: 6,
    isAsc: undefined,
    orderBy: undefined,
    orderByColumn: undefined,
    rand:Math.random()
    
})
const { proxy } = getCurrentInstance();
const gotoMore=()=>{
      const obj = { path: "/home/todoList/", name: "needtodoList" };
      router.push(obj)

}

function openDetail(row){

   ViewPageRef.value.view(row)
}
function authorSuccess(params) {
  //  queryParam.pageNum=1
  //  getList()
       //关闭全部tab

const  view={fullPath:"/index",name:"Index",path:"/index",title:"首页"}
 proxy.$tab.refreshPage(view);

}
function getList() {
  loading.value = true;
   homeApi.needTodoList(queryParam).then(response => {
    needdoList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  }).catch(err=>{loading.value = false;});
}
onMounted(async() => {

let  res  =  await homeApi.needTodoList(queryParam);
if(res){
   loading.value = false;
  needdoList.value=res.rows
}
})
</script>

<style scoped lang="scss">
@import url("../index.scss");

</style>
